<?php
namespace app\admin\model;

use \think\Model;
class StudentCourse extends \think\Model{
    protected $table = 'edu_student_course';
    protected $pk = "cos_id";

    public function batchInsert($stuids,$data){
        $value = '';
        $sql = '';
        if(is_array($data)){
            foreach($data as $d){
                $value .=', ';
                if(is_string($d)){
                    $value .= "'".$d."'";
                    
                }else{
                    $value .= "$d";
                }
            }
        }
        if(is_array($stuids))
        {
            foreach($stuids as $key=>$id)
            {
                $sql .= "(".$id.$value."),";
            }
        }
        $sql = trim($sql,",");
        $sql = "insert into ".$this->getTable()." (stu_id,cos_title,cos_begin,cos_close,cos_content,cos_sort,cos_exercise,cos_mark,cos_createtime) values ".$sql.";";
        return $this->query($sql);
    }

    public function getInfo(){
        $sql = "select s.*, c.* from ".$this->getTable()." as c left join ".$this->getTable('student'). " as s on c.cos_stuid = s.stu_id;";
        // var_dump($sql);
        return $this->query($sql);
    }
}
